package com.adou.second.day8;

import java.io.File;

/**
 * file类判断与获取功能
 * @author admin
 *
 */
public class FileDemo02 {
	public static void main(String[] args) {
		File file = new File("D:\\File\\f001\\java.txt");
		System.out.println("isDirectory:" + file.isDirectory());
		System.out.println("isFile:" + file.isFile());
		System.out.println("exists:" + file.exists());
		
		System.out.println("getPath:" + file.getPath());
		System.out.println("getAbsolutePath:" + file.getAbsolutePath());
		System.out.println("getName:" + file.getName());
		
		System.out.println("============================");
		// 文件
		File fil2 = new File("D:\\File\\f001\\");
		
		// 遍历文件名
		for (String fStr : fil2.list()) {
			System.out.println("file:" + fStr);
		}
		
		System.out.println("============================");
		
		// 遍历文件名
		for (File f : fil2.listFiles()) {
			if(f.isFile()) {
				System.out.println("file:" + f);
			}
			
		}
		
		
		
		
	}
}
